import tornado.ioloop
import tornado.web


class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        # 1.获取数据
        # name = self.get_query_argument('name')
        # ages = self.get_query_arguments('ages')
        name = self.get_argument('name')
        ages = self.get_arguments('ages')
        print(name, ages)
        # http://localhost:8888/?name=123&ages=qqq&ages=222
        self.write('Hello, world')

    def post(self):
        # 2.获取数据
        # bname = self.get_body_argument('bname')
        # bages = self.get_body_arguments('bages')
        breakpoint()
        bname = self.get_argument('bname')
        bages = self.get_arguments('bages')
        print(bname, bages)
        self.write('post ok')


def make_app():
    return tornado.web.Application([
        (r'/', IndexHandler),
    ], debug=True)


if __name__ == '__main__':
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
